Skip to content

Conversation

tshepang
Copy link
Member

…t exist

I think the times I encountered this, I had to check first if files without extensions were added, since all examples only had files with existing extensions.

Also, this replaced example already has a similar example below.

@rustbot
Copy link
Collaborator

rustbot commented May 24, 2025

r? @ChrisDenton

rustbot has assigned @ChrisDenton.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 24, 2025
@lolbinarycat
Copy link
Contributor

I think it would also make sense to show what the output of with_extension("") is, since that's done in the example but only as a round-trip, not actually showing its output.

also, you say there's already a "similar" example, but the .tar.gz example is there to show the case of multiple extensions, while the .rs example is there to show the base case.

if any example is redundant, i think it would be the .tar.xz example, but we could also just add an example without removing anything.

(disclaimer: not part of t-libs)

@ChrisDenton
Copy link
Member

I like adding an example for the no extension case but I would agree that replacing the existing example isn't the way to do it. Having three examples seems fine (maybe with a brief comment pointing out what it's showing).

Personally I'd be minded to split this into two separate code blocks as the multiple extension case is a little more involved than the simpler cases. But I don't feel strongly about that.

@tshepang
Copy link
Member Author

added commit to reduce visual noise... happy to remove if relying on type coercion is not ideal

@ChrisDenton
Copy link
Member

Thanks!

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented May 28, 2025

📌 Commit 248f4b2 has been approved by ChrisDenton

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 28, 2025
jieyouxu added a commit to jieyouxu/rust that referenced this pull request May 28, 2025
Path::with_extension: show that it adds an extension where one did no…

…t exist

I think the times I encountered this, I had to check first if files without extensions were added, since all examples only had files with existing extensions.

Also, this replaced example already has a similar example below.
tgross35 added a commit to tgross35/rust that referenced this pull request May 28, 2025
Path::with_extension: show that it adds an extension where one did no…

…t exist

I think the times I encountered this, I had to check first if files without extensions were added, since all examples only had files with existing extensions.

Also, this replaced example already has a similar example below.
bors added a commit that referenced this pull request May 28, 2025
Rollup of 7 pull requests

Successful merges:

 - #125087 (Optimize `Seek::stream_len` impl for `File`)
 - #133823 (Use `cfg_attr_trace` in AST with a placeholder attribute for accurate suggestion)
 - #138285 (Stabilize `repr128`)
 - #139994 (add `CStr::display`)
 - #141477 (Path::with_extension: show that it adds an extension where one did no…)
 - #141533 (clean up old rintf leftovers)
 - #141693 (Subtree update of `rust-analyzer`)

r? `@ghost`
`@rustbot` modify labels: rollup
tgross35 added a commit to tgross35/rust that referenced this pull request May 28, 2025
Path::with_extension: show that it adds an extension where one did no…

…t exist

I think the times I encountered this, I had to check first if files without extensions were added, since all examples only had files with existing extensions.

Also, this replaced example already has a similar example below.
bors added a commit that referenced this pull request May 28, 2025
Rollup of 8 pull requests

Successful merges:

 - #125087 (Optimize `Seek::stream_len` impl for `File`)
 - #138285 (Stabilize `repr128`)
 - #139994 (add `CStr::display`)
 - #141477 (Path::with_extension: show that it adds an extension where one did no…)
 - #141533 (clean up old rintf leftovers)
 - #141690 (Add `rustc_diagnostic_item` to `sys::Mutex` methods)
 - #141693 (Subtree update of `rust-analyzer`)
 - #141702 (Add eholk to compiler reviewer rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request May 29, 2025
Rollup of 16 pull requests

Successful merges:

 - #136429 (GCI: At their def site, actually wfcheck the where-clause & always eval free lifetime-generic constants)
 - #138139 (Emit warning while outputs is not exe and prints linkage info)
 - #141104 (Test(fs): Fix `test_eq_windows_file_type` for Windows 7)
 - #141477 (Path::with_extension: show that it adds an extension where one did no…)
 - #141533 (clean up old rintf leftovers)
 - #141612 (Call out possibility of invariant result in variance markers)
 - #141638 (Use `builtin_index` instead of hand-rolling it)
 - #141643 (ci: verify that codebuild jobs use ghcr.io)
 - #141675 (Reorder `ast::ItemKind::{Struct,Enum,Union}` fields.)
 - #141680 (replace TraitRef link memory.md)
 - #141682 (interpret/allocation: Fixup type for `alloc_bytes`)
 - #141683 (Handle ed2021 precise capturing of unsafe binder)
 - #141684 (rustbook: Bump versions of `onig` and `onig_sys`)
 - #141687 (core: unstably expose atomic_compare_exchange so stdarch can use it)
 - #141690 (Add `rustc_diagnostic_item` to `sys::Mutex` methods)
 - #141702 (Add eholk to compiler reviewer rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ffdd3b1 into rust-lang:master May 29, 2025
6 checks passed
@rustbot rustbot added this to the 1.89.0 milestone May 29, 2025
rust-timer added a commit that referenced this pull request May 29, 2025
Rollup merge of #141477 - tshepang:patch-1, r=ChrisDenton

Path::with_extension: show that it adds an extension where one did no…

…t exist

I think the times I encountered this, I had to check first if files without extensions were added, since all examples only had files with existing extensions.

Also, this replaced example already has a similar example below.
@tshepang tshepang deleted the patch-1 branch May 29, 2025 12:30
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request May 30, 2025
Path::with_extension: show that it adds an extension where one did no…

…t exist

I think the times I encountered this, I had to check first if files without extensions were added, since all examples only had files with existing extensions.

Also, this replaced example already has a similar example below.
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Jun 2, 2025
Rollup of 16 pull requests

Successful merges:

 - rust-lang/rust#136429 (GCI: At their def site, actually wfcheck the where-clause & always eval free lifetime-generic constants)
 - rust-lang/rust#138139 (Emit warning while outputs is not exe and prints linkage info)
 - rust-lang/rust#141104 (Test(fs): Fix `test_eq_windows_file_type` for Windows 7)
 - rust-lang/rust#141477 (Path::with_extension: show that it adds an extension where one did no…)
 - rust-lang/rust#141533 (clean up old rintf leftovers)
 - rust-lang/rust#141612 (Call out possibility of invariant result in variance markers)
 - rust-lang/rust#141638 (Use `builtin_index` instead of hand-rolling it)
 - rust-lang/rust#141643 (ci: verify that codebuild jobs use ghcr.io)
 - rust-lang/rust#141675 (Reorder `ast::ItemKind::{Struct,Enum,Union}` fields.)
 - rust-lang/rust#141680 (replace TraitRef link memory.md)
 - rust-lang/rust#141682 (interpret/allocation: Fixup type for `alloc_bytes`)
 - rust-lang/rust#141683 (Handle ed2021 precise capturing of unsafe binder)
 - rust-lang/rust#141684 (rustbook: Bump versions of `onig` and `onig_sys`)
 - rust-lang/rust#141687 (core: unstably expose atomic_compare_exchange so stdarch can use it)
 - rust-lang/rust#141690 (Add `rustc_diagnostic_item` to `sys::Mutex` methods)
 - rust-lang/rust#141702 (Add eholk to compiler reviewer rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants